from django.db import models


class ScheduleQueueconf(models.Model):
    '''
    队列表
    '''

    queue_name = models.CharField(max_length=64)
    routing_key = models.CharField(max_length=64)

    class Meta:
        db_table = 'schedule_queue_conf'


class ScheduleCronConf(models.Model):
    '''
    定时任务表
    '''

    schedule_name = models.CharField(max_length=64)
    # 任务名称
    task_name = models.CharField(max_length=64)
    # 任务路径，去掉任务名称的
    task_path = models.CharField(max_length=255)
    # hour
    task_hour = models.IntegerField(null=True)
    # minute
    task_minute = models.IntegerField(null=True)
    task_desc = models.CharField(max_length=255)
    is_active = models.IntegerField(default=1)
    task_args = models.CharField(max_length=255)
    task_kwargs = models.CharField(max_length=255)
    queue = models.ForeignKey('ScheduleQueueconf', models.DO_NOTHING, blank=True, null=True)

    class Meta:
        db_table = 'schedule_cron_conf'


class ScheduleCronConfLog(models.Model):
    '''
    定时任务结果表
    '''

    status = models.CharField(max_length=64)
    user_time = models.CharField(max_length=64)
    cron = models.ForeignKey('ScheduleCronConf', models.DO_NOTHING, blank=True, null=True)

    class Meta:
        db_table = 'schedule_cron_conf_log'
